<template>
  <div>
    <el-form
      :model="ruleForm"
      :rules="rules"
      ref="ruleForm"
      label-width="100px"
      class="demo-ruleForm"
    >
      <el-form-item label="学科" prop="name">
        <el-input v-model="ruleForm.name"></el-input>
      </el-form-item>
      <el-form-item label="年级" prop="region">
        <el-select v-model="ruleForm.region" placeholder="请选择年级">
          <el-option label="一年级" value="yinianji"></el-option>
          <el-option label="二年级" value="ernianji"></el-option>
          <el-option label="三年级" value="sannianji"></el-option>
          <el-option label="四年级" value="sinianji"></el-option>
          <el-option label="五年级" value="wunianji"></el-option>
          <el-option label="六年级" value="liunianji"></el-option>
          <el-option label="初一" value="chuyi"></el-option>
          <el-option label="初二" value="chuer"></el-option>
          <el-option label="初三" value="chusan"></el-option>
          <el-option label="高一" value="gaoyi"></el-option>
          <el-option label="高二" value="gaoer"></el-option>
          <el-option label="高三" value="gaosan"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
    <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
    <el-button @click="resetForm('ruleForm')">重置</el-button>
  </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      ruleForm: {
        name: "",
        region: "",
      },
      rules: {
        name: [
          { required: true, message: "", trigger: "blur" },
          { min: 3, max: 5, message: "", trigger: "blur" },
        ],
        region: [
          { required: true, message: "请选择年级", trigger: "change" },
        ],
      },
    };
  },
  methods: {
    submitForm(formName) {
      this.$router.push("/xklb")
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
};
</script>

<style>
</style>